cmake_minimum_required(VERSION 3.20)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# 设置共享库的输出目录为 ./lib
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib)
project(test VERSION 0.1.0 LANGUAGES C CXX)

# 包含头文件目录
include_directories(${CMAKE_SOURCE_DIR}/src)
# 生成添加共享库
# add_library(sum_fun SHARED ${CMAKE_SOURCE_DIR}/src/sum.cpp ${CMAKE_SOURCE_DIR}/src/cal.cpp)
# add_library(min_fun SHARED ${CMAKE_SOURCE_DIR}/src/minute.cpp ${CMAKE_SOURCE_DIR}/src/cal.cpp)


# 设置共享库的搜索路径
link_directories(${CMAKE_SOURCE_DIR}/lib)
# 生成可执行文件
add_executable(main ${CMAKE_SOURCE_DIR}/src/main.cpp)
# 链接共享库

target_link_libraries(main sum_fun min_fun dl)

# 确保共享库在运行时可以被找到
set_target_properties(main PROPERTIES
    BUILD_RPATH "$ORIGIN/../lib"
)